#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int count_month(int year, int month);
int is_leap(int year);
int main()
{
    int month;
    int year;
    while (scanf("%d%d", &year, &month) == 2)
    {
        printf("%d", count_month(year, month));
    }
    return 0;
}
int count_month(int year, int month)
{
    int temp = 0;
    int  a[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
    if (is_leap(year) && month == 2)
        temp = 29;
    else
        temp = a[month];
    return temp;
}


int is_leap(int year)
{
    return year % 4 == 0 && year % 100 != 0 || year % 400 == 0;
}